﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace simWaifu
{
    //
    // small helper class for comparing dates, times, ...
    //

    public static class DateTimeHelper
    {

        // check if a specified date lies in the future
        public static bool IsInThePast(DateTime dt)
        {
            return (dt.CompareTo(DateTime.Now) < 0);
        }

        // returns the next time (including date) the specified time of day will be
        // if dtPicked lies in the past   the time is set for tomorrow
        // if dtPicked lies in the future the time is set for today
        public static DateTime GetNextTimeWhen(DateTime dtPicked)
        {
            // strip year/month/day
            // only look at time of day from passed object
            // (in case app didn´t run for a while)
            dtPicked = new DateTime(
                DateTime.Now.Year, 
                DateTime.Now.Month, 
                DateTime.Now.Day, 
                dtPicked.Hour, 
                dtPicked.Minute, 
                dtPicked.Second);

            if (IsInThePast(dtPicked))
            {
                dtPicked = new DateTime(
                    DateTime.Now.Year,
                    DateTime.Now.Month,
                    DateTime.Now.Day+1,
                    dtPicked.Hour,
                    dtPicked.Minute,
                    dtPicked.Second);
            }
            return dtPicked;
        }
    }
}
